<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<!--<form id="loginform" action="/common/abc" method="post">-->
<!--    username:<input id="u" type="text" name="username"><br>-->
<!--    password:<input id="p" type="text" name="password"><br>-->
<!--    <input name="remember-me" type="checkbox" value="true"/>记住我<br>-->
<!--    <button id="btn1111111" type="submit" >提交111</button>-->
<!--</form>-->

<button id="btn" type="button">提交</button>
<text>mq</text>
<span id="msg"></span>
<script src="/js/jquery.min.js"></script>
<script>
    $('#btn').on('click', function () {
        sendRequest();
    })

    function sendRequest() {
        var maxVal = Number.MAX_VALUE;
        var minVal = Number.MIN_VALUE;
        let arr =
            [123, 456, 7892222222.333333333, " abc "];
        // arr[0] = 123;
        // arr[1] = 789;
        // arr[2] = 456;
        // var data = "{\"idList\":" +JSON.stringify(arr)+"}";
        // var a ={"abcd":"bbb","123":arr.toString()}
        var a =
            11111222223333344455555555555555555555511111222223333344455555555555555555555511111111111111111111111.33333333333333333333
        $.ajax({
            url: '/test/abcd',
            type: "post",
            dataType: "json",
            // contentType: "application/x-www-form-urlencoded",
            contentType: "application/json;charset=utf-8",
            // cache: false,
            // crossDomain: true,
            // xhrFields: {
            //     withCredentials: true
            // },
            data: JSON.stringify(a),
            success: function (res) {
                console.log("res" + JSON.stringify(res));
            },
            error: function (xhr, textStatus, errorThrown) {
                console.log("ajax request error")
                /*错误信息处理*/
                console.log("进入error---");
                console.log("状态码：" + xhr.status);
                console.log("状态:" + xhr.readyState);//当前状态,0-未初始化，1-正在载入，2-已经载入，3-数据进行交互，4-完成。
                console.log("错误信息:" + xhr.statusText);
                console.log("返回响应信息：" + xhr.responseText);//这里是详细的信息
                console.log("请求状态：" + textStatus);
                console.log(errorThrown);
                console.log("请求失败")
            }
        });
    }
</script>
</body>
<script src="https://cdn.bootcss.com/stomp.js/2.3.3/stomp.js"></script>
<script src="https://cdn.bootcss.com/sockjs-client/1.1.4/sockjs.js"></script>
<script src="http://lib.sinaapp.com/js/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
    // 初始化 ws 对象
    var ws = new WebSocket('ws://121.196.37.50:15674/ws');

    // 获得Stomp client对象
    var client = Stomp.over(ws);

    // 定义连接成功回调函数
    var on_connect = function (x) {
        //data.body是接收到的数据
        client.subscribe("/exchange/testMsg", function (data) {
            var msg = data.body;
            $("#msg").text(msg);
        });
    };

    // 定义错误时回调函数
    var on_error = function () {
        console.log('error');
    };
    // 连接RabbitMQ
    client.connect('wubc683', 'Ab1234', on_connect, on_error, '/');
</script>
</html>

